//
//  DDCategoryManager.m
//  Dingdong
//
//  Created by 程强 on 16/11/24.
//  Copyright © 2016年 程强. All rights reserved.
//

#import "DDCategoryManager.h"
#import "DDCategorySet.h"

@implementation DDCategoryManager
- (DSASubject *)getCategory:(NSNumber *)category_id
{
    DSASubject *subject = [DSASubject subject];
    NSString *doVerifyurl=[NSString stringWithFormat:@"%@wap/cat/get.do", ServerUrl];
    
    NSDictionary *body = @{@"id":category_id};
    NSString *sign = [SystemConfig httpSignWithBody:body];
    
    [KKHttpServices httpPostUrl:doVerifyurl sign:sign prams:body success:^(id responseObject, KKHttpParse *parse) {
        NSDictionary *rdic = parse.responseJsonOB;
        DDCategorySet *set = [DDCategorySet modelWithDictionary:rdic];
        [subject sendNext:set];
        [subject sendCompleted];
    } failure:^(KKHttpParse *parse) {
        NSError* err = nil;
        [KKHttpServices creatHttpErr:parse err:&err];
        [subject sendError:err];
        [subject sendCompleted];
    } cancel:^(NSURLSessionDataTask *task) {
        __strong DSASubject *dsaSubject = subject;
        [subject setDispose:^{
            [task cancel];
            [dsaSubject sendCompleted];
        }];
    }];
    return subject;
}
@end
